﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
//using System.ComponentModel.Composition;
using System.Drawing;
////using System.Linq;
using System.Text;
////using System.Threading.Tasks;
using System.Windows.Forms;
using TRicheControl.DefaultControlStyles;
using TRicheControl.Interface.ControlStyle;

namespace TRicheControl
{
    public class GraphicsStyle
    {
        private static GraphicsStyle mGraphicsStyle = new GraphicsStyle();
        public static GraphicsStyle Styles
        {
            get
            {
                if (mGraphicsStyle == null)
                {
                    mGraphicsStyle = new GraphicsStyle();
                }
                return mGraphicsStyle;
            }
        }

        private GraphicsStyle()
        {
            try
            {
                //MEFHelper.CompositionContainer.ComposeParts(this);
            }
            catch 
            {
            }
        }

        private IButtonStyle mButtonStyle;
        public IButtonStyle ButtonStyle
        {
            get
            {
                if (mButtonStyle == null)
                {
                    mButtonStyle = new ButtonStyle();
                }
                return mButtonStyle;
            }
        }

        private IRadioButtonStyle mRadioButtonStyle;
        public IRadioButtonStyle RadioButtonStyle
        {
            get
            {
                if (mRadioButtonStyle == null)
                {
                    mRadioButtonStyle = new RadioButtonStyle();
                }
                return mRadioButtonStyle;
            }
        }

        private ICheckBoxStyle mCheckBoxStyle;
        public ICheckBoxStyle CheckBoxStyle
        {
            get
            {
                if (mCheckBoxStyle == null)
                {
                    mCheckBoxStyle = new CheckBoxStyle();
                }
                return mCheckBoxStyle;
            }
        }

        private IMenuBarStyle mMenuBarStyle;
        public IMenuBarStyle MenuBarStyle
        {
            get
            {
                if (mMenuBarStyle == null)
                {
                    mMenuBarStyle = new MenuBarStyle();
                }
                return mMenuBarStyle;
            }
        }

        private ITextBoxStyle mTextBoxStyle;
        public ITextBoxStyle TextBoxStyle
        {
            get
            {
                if (mTextBoxStyle == null)
                {
                    mTextBoxStyle = new TextBoxStyle();
                }
                return mTextBoxStyle;
            }
        }

        private IListBoxStyle mListBoxStyle;
        public IListBoxStyle ListBoxStyle
        {
            get
            {
                if (mListBoxStyle == null)
                {
                    mListBoxStyle = new ListBoxStyle();
                }
                return mListBoxStyle;
            }
        }

        private IListBoxItemStyle mListBoxItemStyle;
        public IListBoxItemStyle ListBoxItemStyle
        {
            get
            {
                if (mListBoxItemStyle == null)
                {
                    mListBoxItemStyle = new ListBoxItemStyle();
                }
                return mListBoxItemStyle;
            }
        }

        private IVScrollBarStyle mVScrollBarStyle;
        public IVScrollBarStyle VScrollBarStyle
        {
            get
            {
                if (mVScrollBarStyle == null)
                {
                    mVScrollBarStyle = new VScrollBarStyle();
                }
                return mVScrollBarStyle;
            }
        }

        private ITreeViewStyle mTreeViewStyle;
        public ITreeViewStyle TreeViewStyle
        {
            get
            {
                if (mTreeViewStyle == null)
                {
                    mTreeViewStyle = new TreeViewStyle();
                }
                return mTreeViewStyle;
            }
        }

        public static StringAlignment GetStringAlignment(ContentAlignment align, bool isLineAlignment)
        {
            if (isLineAlignment == true)
            {
                switch (align)
                {
                    case ContentAlignment.TopLeft:
                    case ContentAlignment.TopRight:
                    case ContentAlignment.TopCenter:
                        return StringAlignment.Near;
                    case ContentAlignment.BottomCenter:
                    case ContentAlignment.BottomRight:
                    case ContentAlignment.BottomLeft:
                        return StringAlignment.Far;
                    case ContentAlignment.MiddleCenter:
                    case ContentAlignment.MiddleLeft:
                    case ContentAlignment.MiddleRight:
                    default: return StringAlignment.Center;
                }
            }
            else
            {
                switch (align)
                {
                    case ContentAlignment.MiddleRight:
                    case ContentAlignment.TopRight:
                    case ContentAlignment.BottomRight:
                        return StringAlignment.Near;
                    case ContentAlignment.MiddleLeft:
                    case ContentAlignment.TopLeft:
                    case ContentAlignment.BottomLeft:
                        return StringAlignment.Far;
                    case ContentAlignment.MiddleCenter:
                    case ContentAlignment.BottomCenter:
                    case ContentAlignment.TopCenter:
                    default: return StringAlignment.Center;
                }
            }
        }
    }
}
